<template>
  <div>
    <a-table :data="list" :pagination="false" class="table-two-line mt10" size="mini" :scroll="{ y: 300 }">
      <template #columns>
        <a-table-column title="资料类型" #cell="{ record }">{{ record.type }}</a-table-column>
        <a-table-column title="附件" #cell="{ record }">
          <img width="40" height="40" v-if="record.fileType != 'img'" :src="typMap[record.fileType || 'sub']" alt="" />
          <img style="width: 40px; height: 40px" v-else :src="record.url" alt="" />
          <!-- <img width="40" height="40" :src="typMap[record.fileType || 'sub']" alt="" /> -->
        </a-table-column>
        <a-table-column title="资料名称" #cell="{ record }">
          <TextLimit :rows="1" position="top">{{ record.name }}</TextLimit>
        </a-table-column>
        <a-table-column title="操作人" #cell="{ record }">
          {{ record.createUname }}
        </a-table-column>
        <a-table-column title="操作时间" #cell="{ record }">
          {{ $setTime(record.gmtCreate) }}
        </a-table-column>
        <a-table-column title="操作" #cell="{ record }" width="60">
          <a-button class="ml10" type="text" @click="download(record)">下载</a-button>
        </a-table-column>
      </template>
    </a-table>
  </div>
</template>

<script lang="ts">
  import { defineComponent, ref, reactive, toRefs } from 'vue'
  import world from '@/assets/word.png'
  import excel from '@/assets/excel-.png'
  import pdf from '@/assets/pdf1.png'
  import cad from '@/assets/CAD.png'
  import psd from '@/assets/psd.png'
  import sub from '@/assets/yuanwenjian-1.png'
  export default defineComponent({
    setup() {
      const data: any = reactive({
        list: [],
        typMap: {
          world: world,
          excel: excel,
          pdf: pdf,
          cad: cad,
          psd: psd,
          sub: sub,
        },
      })
      const init = (info: any) => {
        data.list = info?.productInfoList || []
        console.log(data.list)
      }
      const download = (info: any) => {
        let a = document.createElement('a')
        a.target = '_blank'
        a.href = info.url
        a.click()
      }
      return {
        ...(toRefs(data) as any),
        init,
        download,
      }
    },
  })
</script>

<style lang="less" scoped></style>
